﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AdTech.Snap.Test
{
    /// <summary>
    /// This is a test class for DefaultConfigurationTest and is intended
    /// to contain all DefaultConfigurationTest Unit Tests
    /// </summary>
    [TestClass()]
    public class DefaultConfigurationTest
    {
        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        /// A test for Clone
        /// </summary>
        [TestMethod()]
        public void CloneTest()
        {
            IConfiguration cfg = DefaultConfiguration.Default();
            cfg.UseDropbox = true;
            cfg.DefaultFileDestination = Environment.CurrentDirectory;
            cfg.DropboxUID = 666;
            IConfiguration clone = cfg.Clone();
            Assert.AreNotEqual(clone, cfg);
            Assert.AreEqual(clone.DefaultFileDestination, cfg.DefaultFileDestination);
            Assert.AreEqual(clone.DropboxUID, cfg.DropboxUID);
            Assert.AreEqual(clone.OverlayColor, cfg.OverlayColor);
            Assert.AreEqual(clone.OverlayColorOpacity, cfg.OverlayColorOpacity);
            Assert.AreEqual(clone.UseDropbox, cfg.UseDropbox);
        }

        /// <summary>
        /// A test for Create
        /// </summary>
        [TestMethod()]
        public void CreateTest()
        {
            IConfiguration cfg = DefaultConfiguration.Create();
            Assert.AreEqual(null, cfg.DefaultFileDestination);
            Assert.AreEqual(0, cfg.DropboxUID);
            Assert.AreEqual(null, cfg.OverlayColor);
            Assert.AreEqual(0, cfg.OverlayColorOpacity);
            Assert.AreEqual(false, cfg.UseDropbox);
        }

        /// <summary>
        /// A test for Default
        /// </summary>
        [TestMethod()]
        public void DefaultTest()
        {
            IConfiguration cfg = DefaultConfiguration.Default();
            Assert.AreEqual(0.6, cfg.OverlayColorOpacity);
            Assert.AreEqual("Black", cfg.OverlayColor);
            Assert.AreEqual(0, cfg.DropboxUID);
            Assert.AreEqual(false, cfg.UseDropbox);
        }

        /// <summary>
        /// A test for MapFrom
        /// </summary>
        [TestMethod()]
        public void MapFromTest()
        {
            IConfiguration empty = DefaultConfiguration.Create();
            IConfiguration cfg = DefaultConfiguration.Default();
            cfg.UseDropbox = true;
            cfg.DefaultFileDestination = Environment.CurrentDirectory;
            cfg.DropboxUID = 666;
            empty.MapFrom(cfg);
            Assert.AreNotEqual(empty, cfg);
            Assert.AreEqual(empty.DefaultFileDestination, cfg.DefaultFileDestination);
            Assert.AreEqual(empty.DropboxUID, cfg.DropboxUID);
            Assert.AreEqual(empty.OverlayColor, cfg.OverlayColor);
            Assert.AreEqual(empty.OverlayColorOpacity, cfg.OverlayColorOpacity);
            Assert.AreEqual(empty.UseDropbox, cfg.UseDropbox);
        }
    }
}
